{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "#-*- coding: utf-8 -*-"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 变量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "#2.1 变量定义二要素 变量名 赋值\n",
    "x = 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n",
      "False\n"
     ]
    }
   ],
   "source": [
    "#2.2 变量的命名 大写字母 小写字母 数字 下划线  及其组合\n",
    "#严格区分大小写 首字母不能为数字 变量名中间不能有空格 不能与33个python的保留字相同\n",
    "#变量名要尽可能有实际意义 用下划线连接多个单词 变量名由多个单词组成 使用驼峰体（推荐：类名） \n",
    "#尽量避免使用中文和拼音作为变量名\n",
    "#特殊的变量-常量 约定俗成变量名所有字母均大写\n",
    "Python_is_ = True\n",
    "python_is_ = False\n",
    "print (Python_is_)\n",
    "print (python_is_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "20\n",
      "30\n"
     ]
    }
   ],
   "source": [
    "#2.3 变量的赋值\n",
    "#一般赋值 通过等号自右向左赋值\n",
    "x = 1+2\n",
    "#增量赋值\n",
    "x = 10\n",
    "x = x+10\n",
    "print (x)\n",
    "x += 10\n",
    "print (x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 2\n"
     ]
    }
   ],
   "source": [
    "#2.3 打包赋值 同时对多个变量进行赋值\n",
    "x,y = 1,2\n",
    "print (x,y)\n",
    "#互换\n",
    "x,y = y,x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "PI=3.14,E=2.56\n"
     ]
    }
   ],
   "source": [
    "#格式化输出\n",
    "#基本格式： \"字符{0}字符{1}字符\".format(v0,v1)\n",
    "PI = 3.14\n",
    "E = 2.56\n",
    "print(\"PI={0},E={1}\".format(PI,E))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
